package com.woniuxy.ticket.commons.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseResult<T> {
    private int statusCode;		// 状态码：后台处理的结果
    private String message;		// 消息，提示用
    private T data;				// 返回的数据

    public ResponseResult(int statusCode, String message) {
        this(statusCode, message, null);
    }

    public ResponseResult<T> success(T data){
        this.setStatusCode(200);
        this.setMessage("success");
        this.setData(data);
        return this;
    }

    public ResponseResult<T> success(){
        this.setStatusCode(200);
        this.setMessage("success");
        return this;
    }

    public ResponseResult<T> error(){
        this.setStatusCode(500);
        this.setMessage("fail");
        return this;
    }

}
